﻿using System.Collections.Generic;
using System.Configuration;
using System.Web.Mvc;
using DevTrends.MvcDonutCaching;
using ECG.Common;
using ECG.DAL;
using ECG.WebUI.Models;

namespace ECG.WebUI.Controllers
{
    public class ProductNewController : Controller
    {
        //
        // GET: /ProductNew/

        public ActionResult Index(int page = 1)
        {
            ViewBag.Page = page;
            return View();
        }

        [DonutOutputCache(CacheProfile = "HalfDay", VaryByParam = "page")]
        public ActionResult ProductNewList(int page = 1)
        {
            var itemsPerPage = int.Parse(ConfigurationManager.AppSettings["ProductListByCateIdPageSize"]);
            var totalPage = 0;
            var model = ProductDb.GetAllProductNew(page, itemsPerPage, ref totalPage) ?? new List<ProductByCateTopListPagingDto>();
            ViewBag.PageInfo = new PageInfo { CurrentPage = page, PageSize = itemsPerPage, TotalPages = totalPage };
            return PartialView(model);
        }

    }
}
